package com.qinglei.recoup.system.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qinglei.recoup.system.domain.BreathAnalysis;
import com.qinglei.recoup.system.dao.BreathAnalysisMapper;
import com.qinglei.recoup.system.service.BreathAnalysisService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;

/**
 * @author dqh
 */
@Service
public class BreathAnalysisServiceImpl extends ServiceImpl<BreathAnalysisMapper, BreathAnalysis> implements BreathAnalysisService {

@Resource
private  BreathAnalysisMapper breathAnalysisMapper;


    @Override
    public List<BreathAnalysis> getBreathAnalysisList(LocalDate date) {
        LocalDate yesterday = LocalDate.now().minusDays(1);
        if(!Objects.isNull(date)){
           yesterday = date;
        }
        List<BreathAnalysis> breathAnalyses = breathAnalysisMapper.selectList(Wrappers.<BreathAnalysis>lambdaQuery().eq(BreathAnalysis::getDate,yesterday));
        return breathAnalyses;
    }
}
